﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MiniFox.Exceptions
{
    /// <summary>
    /// 表示处理异常事件的方法
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    public delegate void ExceptionEventHandler(object sender, ExceptionEventArgs e);

    /// <summary>
    /// 抽象异常事件参数
    /// </summary>
    public abstract class ExceptionEventArgs : System.EventArgs
    {
        Exception _exception;
        DateTime raiseTime;
        /// <summary>
        /// 
        /// </summary>
        /// <param name="exception"></param>
        protected ExceptionEventArgs(Exception exception)
        {
            this._exception = exception;
            this.raiseTime = DateTime.UtcNow;
        }
        /// <summary>
        /// 异常对象
        /// </summary>
        protected virtual Exception Exception
        {
            get { return _exception; }
        }

        /// <summary>
        /// 异常信息
        /// </summary>
        public string ErrorMessage
        {
            get
            {
                return this._exception.Message;
            }
        }

        /// <summary>
        /// 异常事件引发时间
        /// </summary>
        public DateTime EventRaiseTime
        {
            get
            {
                return this.raiseTime;
            }
        }
    }
}
